#!/bin/bash

#存放结果的变量
ret1=()
ret2=()
ret3=()
ret1[3]=0
ret2[3]=0
ret3[3]=0

#文件处理函数
function handle_file() {
    local filename="$1"
    local curline=1
    while read -r line || [[ -n ${line} ]]; do
        array=($(echo ${line} | tr '[:punct:]' " "))
        for i in ${array[*]}; do
            if [[ "${i}" =~ ^[a-zA-Z]+$ ]] && [[ ${#i} -gt ${ret3[3]} ]]; then
                echo ${i}
                echo ${#i}
                ret3[0]=${filename}
                ret3[1]=${curline}
                ret3[2]=${i}
                ret3[3]=${#i}
                if [[ ${ret3[3]} -gt ${ret2[3]} ]]; then
                    temp=(`echo ${ret2[*]}`)
                    ret2=(`echo ${ret3[*]}`)
                    ret3=(`echo ${temp[*]}`)
                    if [[ ${ret2[3]} -gt ${ret1[3]} ]]; then
                        temp=(`echo ${ret1[*]}`)
                        ret1=(`echo ${ret2[*]}`)
                        ret2=(`echo ${temp[*]}`)
                    fi
                fi
            fi
        done
        ((curline++))
    done < $1
}

handle_file "./append.sh"

echo ${ret1[*]}
echo ${ret2[*]}
echo ${ret3[*]}